<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page import="org.codehaus.groovy.grails.commons.ConfigurationHolder" %>
<%@ page import="net.tribal.comic.entities.User" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="title.user.create"/></title>
    </head>
    
    <body>
		<div class="navButtonsTop rounded-corners">
			<h1 class="title"><g:message code="title.user.create"/></h1>
		</div>
			
		<g:uploadForm action="save">
            <div class="element">
            	<g:hasErrors bean="${userInstance}">
					<div class="errors rounded-corners"><g:renderErrors bean="${userInstance}" as="list" /></div>
		  		</g:hasErrors>
            
            	<div class="tableCreate">
                    <table>
                        <tbody>
                 	        <tr>
                                <td class="name">
                                    <label for="alias"><g:message code="default.label.alias"/>:</label>
                                </td>
                                <td class="focus requiredField value ${hasErrors(bean: userInstance, field: 'alias', 'errors')}" colspan="3">
                                    <g:textField name="alias" size="50" maxlength="50" value="${fieldValue(bean: userInstance, field: 'alias')}" class="focus"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="name">
                                    <label for="name"><g:message code="default.label.name"/>:</label>
                                </td>
                                <td class="requiredField value ${hasErrors(bean: userInstance, field: 'name', 'errors')}">
                                    <g:textField name="name" size="50" maxlength="50" value="${fieldValue(bean: userInstance, field: 'name')}" />
                                </td>
                                <td class="name">
                                    <label for="lastName"><g:message code="default.label.lastName"/>:</label>
                                </td>
                                <td class="requiredField value ${hasErrors(bean: userInstance, field: 'lastName', 'errors')}">
                                    <g:textField name="lastName" size="50" maxlength="50" value="${fieldValue(bean: userInstance, field: 'lastName')}" />
                                </td>
                            </tr>
                        
                            <tr>
                                <td class="name">
                                    <label for="male"><g:message code="default.label.gender"/>:</label>
                                </td>
                                <td class="value ${hasErrors(bean: userInstance, field: 'gender', 'errors')}">
	                                <g:select from="${ConfigurationHolder.config.comics.gender}" name="gender" value="${userInstance?.gender}" valueMessagePrefix="defaulf.select.gender"/>
                                </td>
                                <td class="name">
                                    <label for="birthDate"><g:message code="default.label.birthDate" />:</label>
                                </td>
                                <td class="value ${hasErrors(bean: userInstance, field: 'birthDate', 'errors')}">
                                    <g:datePicker name="birthDate" precision="day" years="${new GregorianCalendar().get(Calendar.YEAR)-100..new GregorianCalendar().get(Calendar.YEAR)}"/>
                                </td>
                            </tr>
                            <tr>
								<td class="name">
                                    <label for="country"><g:message code="default.label.country"/>:</label>
                                </td>
                                <td colspan="3" class="value ${hasErrors(bean: userInstance, field: 'country', 'errors')}">
	                                <g:countrySelect name="country" default="esp" value="${fieldValue(bean:userInstance,field:'country')}"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="name">
                                    <label for="email"><g:message code="default.label.email"/>:</label>
                                </td>
                                <td class="requiredField value ${hasErrors(bean: userInstance, field: 'email', 'errors')}">
                                    <g:textField name="email" size="50" maxlength="50" value="${fieldValue(bean: userInstance, field: 'email')}" />
                                </td>
                                <td  class="name">
                        			<label><g:message code="default.label.path.user.photo"/>:</label>
                        		</td>
                        		<td  class="value ${hasErrors(bean: userInstance, field: 'path', 'errors')}">
                        			<input type="file" name="file"/>
                        		</td>
                            </tr>
                            <tr>
                                <td class="name">
                                    <label for="password"><g:message code="default.label.password"/>:</label>
                                </td>
                                <td class="requiredField value ${hasErrors(bean: userInstance, field: 'password', 'errors')}">
                                    <g:passwordField name="password" size="50" maxlength="50"/>
                                </td>
                                <td class="name">
                                    <label for="repeatPassword"><g:message code="default.label.repeatPassword"/>:</label>
                               	</td>
                               	<td class="requiredField value ${hasErrors(bean:userInstance,field:'password','errors')}">
		                            <g:passwordField name="repeatPassword" size="50" maxlength="50"/>
		                        </td>
                            </tr>
	                        <tr>
                                <td class="name" >
                                    <label for="rateable"><g:message code="default.label.rateable.user.new"/>:</label>
                                </td>
                                <td class="value ${hasErrors(bean: userInstance, field: 'rateable', 'errors')}">
                                    <g:checkBox name="rateable" value="${userInstance?.rateable}" />
                                </td>
		                        <td class="name">
                                    <label for="commentable"><g:message code="default.label.commentable.user.new"/>:</label>
                                </td>
                                <td colspan="3" class="value ${hasErrors(bean: userInstance, field: 'commentable', 'errors')}">
                                    <g:checkBox name="commentable" value="${userInstance?.commentable}" />
                                </td>
                           	</tr>
                           	<tr>
	                           	<td colspan="6">
	                           		<g:textArea id="termsOfUseMessage" name="termsOfUseMessage" value="${message(code:'default.global.termsOfUse')}" rows="5" readonly="true"/>
	                           	</td>
                           	</tr>
                           	<tr>
	                           	<td class="name" colspan="3">
	                           		<g:message code="default.global.termsOfUse.accept"/>:
	                           	</td>
	                           	<td class="value" colspan="3">
	                           		<g:checkBox name="termsOfUse"/>
	                           	</td>
                           	</tr>
                        </tbody>
                    </table>
				</div>
			</div>
	        <div class="navButtons rounded-corners">
				<div class="left">
                	<g:submitButton name="create" class="save" value="${message(code:'default.button.create')}"/>
                </div>
                <div class="right">
                	<g:actionSubmit class="back" action="list" value="${message(code:'default.button.back')}" />
               	</div>
            </div>
       	</g:uploadForm>
    </body>
</html>